package com.cxria.springboottest.repository

import com.cxria.springboottest.entity.User
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Modifying
import org.springframework.data.jpa.repository.Query
import org.springframework.data.repository.query.Param

interface UserRepository extends JpaRepository<User, Long> {

    User findByName(String name)

    @Query("select o from User o where o.username = :username and o.remove = false")
    User findByUsername(@Param("username") String username);

    @Override
    @Query("select o from User o where o.id <> 1 and o.remove = false order by o.id desc")
    List<User> findAll();

}
